home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 422_02 / dosutil / scrub.c < prev    next >
C/C++ Source or Header  |  1994-03-20  |  1KB  |  53 lines

  1. /*
  2.  * Diskette head cleaner
  3.  *
  4.  * For use with cleaning disks.
  5.  * Moves the disk head back and forth across the entire cleaning disk.
  6.  *
  7.  * Copyright 1991-1994 Dave Dunfield
  8.  * All rights reserved.
  9.  *
  10.  * Permission granted for personal (non-commercial) use only.
  11.  *
  12.  * Compile command: cc scrub -fop
  13.  */
  14. #include <stdio.h>
  15.  
  16. int drive, cylinders, step = 10;
  17.  
  18. main(argc, argv)
  19.     int argc;
  20.     char *argv[];
  21. {
  22.     int i, j;
  23.  
  24.     if(argc < 3)
  25.         abort("Use: scrub <drive> <cylinders> [step]");
  26.     if(((drive = toupper(argv[1][0])-'A') >= 2) || (argv[1][1] != ':'))
  27.         abort("Invalid floppy drive id");
  28.     cylinders = atoi(argv[2]);
  29.     if(argc > 3)
  30.         step = atoi(argv[3]);
  31.  
  32.     for(j=0; j < 5; ++j) {
  33.         seek(drive, 1);
  34.         for(i = step; i < cylinders; i += step) {
  35.             seek(drive, i);
  36.             seek(drive, i - (step/2)); } }
  37. }
  38.  
  39. /*
  40.  * Seek to cylinder on drive
  41.  */
  42. seek(drive, track) asm
  43. {
  44.         MOV        DL,6[BP]    ; Get drive ID
  45.         XOR        AH,AH        ; Funct zero
  46.         INT        13h            ; Reset disk
  47.         MOV        CH,4[BP]    ; Get cylinder
  48.         MOV        AX,0401h    ; Verify funct, 1 sector
  49.         MOV        CL,AL        ; Begin with sector 1
  50.         XOR        DH,DH        ; Head 0
  51.         INT        13h            ; Seek to cylinder
  52. }
  53.